(ns fx-clj.impl.animation
  (:import (javafx.util Duration)))

;; Duration

(def duration-zero (Duration/ZERO))

(def duration-one (Duration/ONE))

(def duration-indefinite (Duration/INDEFINITE))

(def duration-unknown (Duration/UNKNOWN))

(defn duration* [s factory]
  (factory s))

(defmacro duration [s unit]
  (let [unit (condp = unit
               'ms #(Duration/millis %)
               's #(Duration/seconds %)
               'm #(Duration/minutes %)
               'h #(Duration/hours %)
               :else (throw (IllegalArgumentException. "The unit parameter must be one of [ms|s|m|h]")))]
    `(duration* ~s ~unit)))